const express = require('express')

const app =express()

app.get('/userPath/:userId',(request,response)=>{
    const {userId}=request.params//这里的键要和接收params参数的名字相同
    if(userId!=='3'){
        return response.send({
            code:10001,
            msg:'获取失败',
            data:'null'

        })
    }
    response.send({
        code:10000,
        msg:'获取成功',
        data:{
            name:'高',
            age:18,
            sex:'female'
        }
    })
})

//展示页面的接口
app.get('/3',(request,response)=>{
    response.sendFile(__dirname+'/get请求之path传参.html')

})

app.listen(8886,()=>{
    console.log('成功,请访问http://127.0.0.1:8886')
})